/*
 * DoString.h
 *
 *  Created on: Oct 18, 2012
 *      Author: wtao
 */

#ifndef DOSTRING_H_
#define DOSTRING_H_

#include "_DoObject.h"
#include <iomanip>

class DoString: public _DoObject 
{
public:
	enum eType {
		ePlain,
		eAscii85,
		eHex
	};
protected:
	DoString(const DoString&);
	DoString& operator=(const DoString&);

	eType mType;
	
	ostringstream mHexLiteral;

public:
	DoString();
	virtual ~DoString();

	virtual std::string _debug_dump() const;
	
	virtual bool equals(CRefPtr< _DoObject > obj) {
		return compare(toString(obj)) == 0;
	}
	
	eType getType() {
		return mType;
	}
	
	int compare(DoString *obj) {
		if (mType != ePlain && obj->getType() != ePlain)
			CXXTHROW;
		return mText.compare(obj->getText()) == 0;
	}

	void parseHex(std::string &str);
	
	void parseAscii85(std::string &str);
	
	std::string getHex() {
		return mHexLiteral.str();
	}
	
	std::string& getAscii85() {
		return mText;
	}
	
	std::string& getPlain() {
		return mText;
	}
	
	void setHex(const std::string& str) {
		mHexLiteral.str(str);
	}
	
	void _debug_hex(const std::string & path) const;
};

#endif /* DOSTRING_H_ */
